package com.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class TestOrderId {
    public static void main(String[] args) {
        //获取当前时间
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");
        Date d = new Date(System.currentTimeMillis());
        System.out.println("当前日期时间为：" + formatter.format(d));
        System.out.println("===================");

        SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");
        Date d1 = new Date(System.currentTimeMillis());
        System.out.println("去掉格式的当前日期时间为：" + formatter1.format(d1));
        //就诊号
        String oreder = "";
        oreder = oreder + formatter1.format(d1);
        System.out.println("订单号+日期+时间：" + oreder);

        //生成随机三位数
        Random r = new Random();
        //在1000-9999
        int rand = r.nextInt(900) + 100;
        System.out.println("随机数为：" + rand);

        oreder = oreder + rand;
        System.out.println("订单号+日期+时间+随机数：" + oreder);

        System.out.println("您的订单号为：" + oreder);

        System.out.println("============获取订单号的日期================");
        String jiequ = oreder;
        System.out.println("订单号截取的日期+时间：" + jiequ.substring(0, 14));
        int year = Integer.parseInt(jiequ.substring(0, 4));
        int month = Integer.parseInt(jiequ.substring(4, 6));
        int day = Integer.parseInt(jiequ.substring(6, 8));
        int hour = Integer.parseInt(jiequ.substring(8, 10));
        int minute = Integer.parseInt(jiequ.substring(10, 12));
        int miao = Integer.parseInt(jiequ.substring(12, 14));
        System.out.println(year + "年");
        System.out.println(month + "月");
        System.out.println(day + "日");
        System.out.println(hour + "时");
        System.out.println(minute + "分");
        System.out.println(miao + "秒");

    }
}
